package mp3seller.daos;

import java.util.ArrayList;
import java.util.HashMap;

import mp3seller.entities.Mp3;
import mp3seller.util.Util;
/**
 * Classe de persistencia padrao DAO para mp3 do sistema
 * @author Raoni
 *
 */
public class Mp3DAO {
	
	private HashMap<Long, Mp3> mp3s = new HashMap<Long, Mp3>();
	/**
	 * salvar mp3
	 * @param mp3
	 */
	public long saveMp3(Mp3 mp3){
		long code = Util.nextCode(mp3s.keySet());
		mp3.setId(code);
		mp3s.put(mp3.getId(), mp3);
		
		return code;
	}
	/**
	 * deletar mp3
	 * @param mp3
	 */
	public void deleteMp3(Mp3 mp3){
		mp3s.remove(mp3.getId());
	}
	/**
	 * atualizar mp3
	 * @param mp3
	 */
	public void updateMp3(Mp3 mp3){
		mp3s.put(mp3.getId(), mp3);
	}
	/**
	 * pegar mp3
	 * @param key
	 * @return
	 */
	public Mp3 getMp3(long key){
		return mp3s.get(key);
	}
	/**
	 * pegar todas as mp3
	 * @return
	 */
	public HashMap<Long, Mp3> getMp3(){
		return mp3s;
	}
	/**
	 * pegar uma mp3 usando sql
	 * @param sql
	 * @return
	 */
	public ArrayList<Mp3> getMp3(String sql){
		return null;
	}

}
